<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group([],function(){
    if (!isset($_SERVER['REQUEST_URI'])) {
        return;
    }
    $arr = explode('/',explode('?',$_SERVER['REQUEST_URI'])[0]);

    $arr[2] = $arr[2] ? $arr[2] : 'index';
    Route::match(['get', 'post'], "$arr[1]/$arr[2]/$arr[3]", value(function() use ($arr){
        foreach($arr as $key=>&$val){
            if($key == 1){
                $val = str_replace(' ','',ucwords(str_replace('_',' ',str_replace('-',' ',$val))));
            }else if($key == 2){
                $val = str_replace(' ','',lcfirst(ucwords(str_replace('_',' ',str_replace('-',' ',$val)))));
            }
        }
        return ucwords($arr[1]) . "\\" . ucwords($arr[2]) . "Controller@" . $arr[3];
    }));
});

Route::match(['get', 'post'], '/server/wxcallback', 'Recharge\CallbackController@wxPayCallback');

Route::get('/r/oauth', 'Recharge\AuthController@oauth');